import type { VNode } from 'vue'
import type { IconTypes } from '../helpers'
import { h } from 'vue'
import Icon from '../Icon.vue'

/**
 * 如果需要在其他组件中如 ElButton 传入 icon 属性，可以使用 useIcon
 * <script setup lang="tsx">
 * import { useIcon } from 'fetm-components'
 * import { ElButton } from 'element-plus'
 * const icon = useIcon({ icon: 'svg-icon:save' })
 * </script>
 * <template>
 *   <ElButton :icon="icon"> button </ElButton>
 * </template>
 */
export function useIcon(props: IconTypes): VNode {
  return h(Icon, props)
}
